<script src="{__GOUGU__}/layui/layui.js"></script>
<div>
    <input type="hidden" id="party_id" value="{$id}">
    <table class="layui-hide" id="lawcase" lay-filter="lawcase"></table>
</div>

<script>
function initLawcase(){
    if($('#partyTab').find('li').eq(0).data('load') == 'true'){
        return false;
    }
    $('#partyTab').find('li').eq(0).data('load','true');

    layui.use(['tool', 'table', 'oaPicker'], function(){
        let tool = layui.tool, table = layui.table, oaPicker = layui.oaPicker;
    
    layui.lawcaseTable = table.render({
        elem: '#lawcase',
        title: '案件列表',
        cellMinWidth:80,
        url: '/lawcase/api/get_party_lawcases',
        where: { party_id: $('#party_id').val() },
        page: true,
        limit: 10,
        parseData: function(res){
            return {
              "code": res.code,
              "msg": res.msg,
              "count": res.count,
              "data": res.data
            };
        },
        cols: [[
            {field: 'case_code', title: '案件编号', width: 180, align:'center'},
            {field: 'court_name', title: '管辖法院'},
            {field: 'case_cause_name', title: '案由'},
            {field: 'stage', title: '阶段'},
            {field: 'status', title: '案件状态'},
            {field: 'lawyer_name', title: '主办律师'},
            {field: 'update_time', title: '更新时间', align: 'center', templet: function(d){
                return layui.util.toDateString(d.update_time * 1000, 'yyyy-MM-dd HH:mm:ss');}},
            {fixed: 'right', width: 120, title: '操作', align:'center', templet: function(d){
                return '<a class="layui-btn layui-btn-xs" lay-event="view">查看</a>';
            }}
        ]]
    });
        

        
        table.on('tool(lawcase)', function(obj){
            var data = obj.data;
            if(obj.event === 'view') {
                tool.side('/lawcase/lawcase/view?id=' + data.case_id, '查看案件');
            
            }
        });
    });
}

</script>